<template>
    <div>
        <h1>信息列表</h1>
        <input type="text" v-model="newName">
        <button @click="ADDPERSON(newName)">添加</button>
        <ul>
            <li v-for="p in personList" :key="p.id">{{ p.name }}</li>
        </ul>
        <h1>Category组件的当前求和为：{{ sum }}</h1>
    </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
    name: 'PersonList',
    data() {
        return {
            newName: ''
        }
    },
    computed: {
        ...mapState('personAbout', ['personList']),
        ...mapState('categoryAbout', ['sum'])
    },
    methods: {
        ...mapMutations('personAbout', ['ADDPERSON'])
    }
}
</script>